from urllib import parse
from apps.staff.tasks import send_mail_task
from django.urls import reverse


def send_active_email(request, email, aes):
    token = aes.encrypt(email)
    active_path = reverse("staff:active_staff") + "?" + parse.urlencode({'token': token})
    # http:127.0.0.1:/8000/staff/active?token=xxx
    active_url = request.build_absolute_uri(active_path)
    message = f"请点击以下链接激活账号：{active_url}"
    subject = '[天穹OA]账号激活'
    send_email = email
    send_mail_task(subject=subject, message=message, email=send_email)
